export default new Vuex.Store({
  state: {
    waitUpdateGoods: {}
  },
  mutations: {
    SET_WAIT_UPDATE_GOODS(state, payload) {
      let { distributorId, goodsId } = payload;
      if (!state.waitUpdateGoods[distributorId]) {
        state.waitUpdateGoods[distributorId] = new Set();
      }
      state.waitUpdateGoods[distributorId].add(goodsId);
    },
    REMOVE_WAIT_UPDATE_GOODS(state, payload) {
      let { distributorId, goodsId } = payload;
      if (!state.waitUpdateGoods[distributorId]) return;
      if (state.waitUpdateGoods[distributorId].has(goodsId)) {
        state.waitUpdateGoods[distributorId].delete(goodsId);
      }
    }
  },
  actions: {},
  getters: {
    waitUpdateGoodsIds(state) {
      return function(distributorId) {
        return state.waitUpdateGoods[distributorId]
          ? state.waitUpdateGoods[distributorId].values()
          : null;
      };
    }
  }
});
